/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const JsonAdapter = require('../JsonAdapter');
const iconv = require("iconv-lite");
const vm = require('vm');
const request = require('request-promise');
const logger = require('../../conf/logger');
const querystring = require("querystring")
const urlencode = require("urlencode")

/**
 * cctv app
 * @type {module.Bjp2p}
 */
module.exports = class WuhuaXuanwen extends JsonAdapter{

    async reqJson(){
        const body = await this.doRequest();
        let decodeBody = iconv.decode(body, this.encoding).toString();
        if(decodeBody.startsWith("[") && decodeBody.endsWith("]")) {
            let data = {};
            data.data=JSON.parse(decodeBody);
            return data;
        }
        let datas = JSON.parse(decodeBody);

        for(let focus of datas.data.focus){
             datas.data.list.push({
                 title:focus.title,
                 newsUrl:focus.shorturl
             });
        }
        return datas;
    }

}
